package com.ruoyi.web.controller.flowable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FormGroups;
import com.ruoyi.system.service.IFormGroupsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 表单分组Controller
 *
 * @author ruoyi
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/flowable/from/groups")
public class FormGroupsController extends BaseController
{
    @Autowired
    private IFormGroupsService formGroupsService;

    /**
     * 查询表单分组列表
     */
    @PreAuthorize("@ss.hasPermi('system:groups:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody FormGroups formGroups)
    {
//        startPage();
        List<FormGroups> list = formGroupsService.selectFormGroupsList(formGroups);
        return getDataTable(list);
    }

    /**
     * 获取表单分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:groups:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(formGroupsService.selectFormGroupsByGroupId(groupId));
    }

    /**
     * 新增表单分组
     */
    @PreAuthorize("@ss.hasPermi('system:groups:add')")
    @Log(title = "表单分组", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FormGroups formGroups)
    {
        return toAjax(formGroupsService.insertFormGroups(formGroups));
    }

    /**
     * 修改表单分组
     */
    @PreAuthorize("@ss.hasPermi('system:groups:edit')")
    @Log(title = "表单分组", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody FormGroups formGroups)
    {
        return toAjax(formGroupsService.updateFormGroups(formGroups));
    }

    /**
     * 删除表单分组
     */
    @PreAuthorize("@ss.hasPermi('system:groups:remove')")
    @Log(title = "表单分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupId}")
    public AjaxResult remove(@PathVariable Long groupId)
    {
        return toAjax(formGroupsService.deleteFormGroupsByGroupId(groupId));
    }
}
